/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package br.siagefi.service;

import br.siagefi.dao.DAO;
import br.siagefi.model.NotaFiscal;
import java.util.List;

/**
 *
 * @author NOTE
 */
public class NotaFiscalService {
    private final DAO<NotaFiscal> dao;

    public NotaFiscalService() {
        this.dao = new DAO<>(NotaFiscal.class);
    }
    
    public void inserir(NotaFiscal notaFiscal){
        dao.adiciona(notaFiscal);
    }
    
    public void alterar(NotaFiscal notaFiscal){
        dao.atualiza(notaFiscal);
    }
    
    public List<NotaFiscal> listar(){
        return dao.listaTodos();
    }
    
    public void remover(NotaFiscal notaFiscal){
        dao.remove(notaFiscal);
    }
    
    public boolean jaExiste(NotaFiscal notaFiscal) {
        List<NotaFiscal> lista = this.listar();
        for (NotaFiscal nf : lista) 
            if(nf.equals(notaFiscal))
                return true;
        return false;
    }
}
